package com.example.springboot.utils;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

public class TransformTime {
    public static String Transform (String inputDateTime) {
        String outputFormat = "yyyy-MM-dd HH:mm:ss";

        SimpleDateFormat inputDateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'");
        SimpleDateFormat outputDateFormat = new SimpleDateFormat(outputFormat);
        String outputDateTime=null;
        try {
            Date date = inputDateFormat.parse(inputDateTime);
            outputDateTime = outputDateFormat.format(date);
            System.out.println(outputDateTime);
        } catch (ParseException e) {
            e.printStackTrace();
        }
        return outputDateTime;
    }

    public static Date TransformString(String dateString ) {
        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        Date date=null;
        try {
            date = dateFormat.parse(dateString);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return date;
    }
}
